<div class="wrapper">
	
	<?php $this->load->view('ucenter/sidebar');?>
	
	<div class="content">
		
		<h3>修改密码</h3>
		<form action="" method="post" id="myPassword">
		<div class="form-group first">
			
			<label for="">原密码</label>
			<input type="password" name="old_password" id="old_password" class="form-control" placeholder="密码6-16位" value="<?php //echo $value->user_nickname; ?>" />
			
		</div>
		
		<div class="form-group">
			
			<label for="">新的密码</label>
			<input type="password" name="new_password" id="new_password" class="form-control" placeholder="密码6-16位" value="<?php //echo $value->real_name; ?>" />
			
		</div>
		
		<div class="form-group">
			
			<label for="">确认新密码</label>
			<input type="password" name="again_password" id="again_password" class="form-control" placeholder="密码6-16位" value="<?php //echo $value->mobile; ?>" />
			
		</div>
		
		
		<div class="form-group">
			
			<label for=""></label>
			<input type="button" name="submitSetting" id="submitPassword" class="btn btn-primary" value="保 存 密 码" />
			
		</div>
		</form>
	</div><!-- content -->


</div>

<script src="<?php echo base_url(); ?>javascript/fenzhong.js"></script>

<script>
//当控件获取焦点时候，则去除错误提示
$("input").focus(function(){
	
	$(this).popover('destroy');
	$(this).parent().removeClass('has-error');
});

function showErrorMessage(id,message){
	clearError(id);
	$(id).parent().addClass('has-error');
	$(id).attr('data-content',message);
	$(id).attr('data-placement','right');
	$(id).attr('data-html','true');
	$(id).popover('show');
	$('#register').button('reset');
	
}
$("#submitPassword").click(function(){
	
	if(!checkInput("#old_password",1,10,"原密码")) return false;
	if(!checkPassword("#new_password","#again_password",6,16)) return false;

	$.ajax({
		url:"<?php echo base_url(); ?>ucenter/savePassword",
		type:"post",
		dataType:"json",
		data:$("#myPassword").serialize(),
		success:function(e){
			if(e.status=='10000'){
				new jBox('Notice', {content:"修改成功",position:{x:"center",y:"center"},color:"green" });
			}else if(e.status=='10611'){
				showErrorMessage("#old_password","原密码必须在6-16位之间");
			}else if(e.status=='10612'){
				showErrorMessage("#new_password","新密码必须在6-16位之间");
			}else if(e.status=='10613'){
				showErrorMessage("#again_password","确认密码必须在6-16位之间");
			}else if(e.status=='10614'){
				showErrorMessage("#new_password","两次输入的密码不一致");
				showErrorMessage("#again_password","两次输入的密码不一致");
			}else if(e.status=='10615'){
				showErrorMessage("#old_password","原密码输入不正确");
			}
			
		}
	});
});

</script>
